const postService = require('../service/post.service')

// 判断是否点赞过
const verifyLike = async (ctx, next) => {
	const { id } = ctx.user
	const { post_id } = ctx.params
	const isLike = await postService.findIsLike(post_id, id)
	ctx.isLike = isLike
	await next()
}

// 判断是否收藏过
const verifyFavority = async (ctx, next) => {
	const { id } = ctx.user
	const { post_id } = ctx.params
	const isFavority = await postService.findIsCollection(post_id, id)
	ctx.isFavority = isFavority
	await next()
}

module.exports = {
	verifyLike,
	verifyFavority
}
